using System;
using System.Collections.Generic;
using System.Text;
using Bussiness.Interfaces;
using System.Data;
using DataProvider;
using Bussiness.Exc;

namespace Bussiness
{
    public class INBAOCAOProcess:IINBAOCAO
    {
        IDBManager idbManager = new DBManager(DataProviderE.SqlServer);

        DataTable IINBAOCAO.XemThang()
        {
            DataTable tbl = null;
            try
            {
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemThang()" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
        DataTable IINBAOCAO.XemLop()
        {
            DataTable tbl = null;
            try
            {
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemLop()" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
        DataTable IINBAOCAO.XemPhieuDiemNamHoc(string maLop)
        {
            DataTable tbl = null;
            try
            {
                idbManager.CreateParameters(1);
                idbManager.AddParameters(0, "@Malop", maLop, ParameterDirection.Input);
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemNamHoc(string maLop)" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
        DataTable IINBAOCAO.XemPhieuDiemNamHoc()
        {
            DataTable tbl = null;
            try
            {
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemNamHoc()" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
        DataTable IINBAOCAO.XemPhieuDiemHocKy(byte hocKy) 
        {
            DataTable tbl = null;
            try
            {
                idbManager.CreateParameters(1);
                idbManager.AddParameters(0, "@HocKy", hocKy, ParameterDirection.Input);
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemHocKy(byte hocKy)" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
        DataTable IINBAOCAO.XemPhieuDiemHocKy() 
        {
            DataTable tbl = null;
            try
            {
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemHocKy()" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
        DataTable IINBAOCAO.XemPhieuDiemThang(string maKT) 
        {
            DataTable tbl = null;
            try
            {
                idbManager.CreateParameters(1);
                idbManager.AddParameters(0, "@MaKT", maKT, ParameterDirection.Input);
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemThang(string maKT)" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
        DataTable IINBAOCAO.XemPhieuDiemThang()
        {
            DataTable tbl = null;
            try
            {
                idbManager.Open();
                tbl = idbManager.ExecuteDataSet(CommandType.StoredProcedure, "").Tables[0];
            }
            catch (DatabaseExc e)
            {
                throw new BussinessExc(e.Message, e.ErrCodeUser, e.ErrCodeSQL);
            }
            catch (Exception e)
            {
                throw new BussinessExc("Bussiness. IINBAOCAO.XemPhieuDiemThang()" + e.Message);
            }
            finally
            {
                idbManager.Dispose();
            }
            return tbl;
        }
    }
}
